import { Action, createAction } from "redux-actions";
import { call, put } from "redux-saga/effects";
import { getMedicalCard } from "../../../utils/RequestUtils";
import { MEDICAL_CARD, MEDICAL_CARD_SET } from "../../types";

export const medicalcardList = createAction(MEDICAL_CARD, (list: []) => {
  return { list };
});

export const medicalcardSet = createAction(
  MEDICAL_CARD_SET,
  (params: object) => {
    return { ...params };
  }
);

export function* getMedicalcard(params: Action<any>) {
  yield put(medicalcardList([]));
  const cardList = yield call(getMedicalCard, params);
  yield put(medicalcardList(cardList.data));
}
